{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from IPython.display import display \n",
    "from PIL import Image\n",
    "import random\n",
    "import json\n",
    "import os\n",
    "\n",
    "f = open('./metadata/all-objects.json')\n",
    "all_images = json.load(f)\n",
    "\n",
    "cid = input(\"IPFS Image CID (): \")\n",
    "if len(cid) > 0:\n",
    "  if not cid.startswith(\"ipfs://\"):\n",
    "    cid = \"ipfs://{}\".format(cid)\n",
    "  if cid.endswith(\"/\"):\n",
    "    cid = cid[:-1]\n",
    "  for i, item in enumerate(all_images):\n",
    "    with open('./metadata/' + str(item[\"tokenId\"]) + '.json', 'r') as infile:\n",
    "      original_json = json.loads(infile.read())\n",
    "      original_json[\"image\"] = original_json[\"image\"] = f'{cid}/{str(item[\"tokenId\"])}.png'\n",
    "      with open('./metadata/' + str(item[\"tokenId\"]) + '.json', 'w') as outfile:\n",
    "        json.dump(original_json, outfile, indent=4)"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
